<!-- #section:aModal start-->
<div id="aModal" class="modal fade">
	<div class="modal-dialog" style="height: 300px;">
		<div class="modal-content" style="width: 800px; left: 50%; margin-left:-400px; top: 10px;">
		<!-- dialog body -->
			<!--<div class="modal-body">-->
			
				<div class="accordion-style1 panel-group" style="margin-bottom: 0px;">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								<div class="accordion-toggle">
									&nbsp;<span id="aModal_title">无标题对话框</span>
									<span id="aModal_refresh_title" class="red bigger-120"></span>
									<button type="button" class="close" data-dismiss="modal">&times;</button>
								</div>
							</h4>
						</div>

						<div id="aModal_msg" class="panel-body">
							<h1 class="center">loading...</h1>
						</div>
						<script type="text/javascript" id="aModal_javascript"></script>

					</div>
				</div>
					
			<!--</div>-->
			
			<!-- dialog buttons -->
			<div class="modal-footer" id="aModal_footer">
				<span class="pull-left" id="aModal_tipmsg" tipstay="0"></span>
				<button type="button" class="hide" id="aModal_btn_0" refresh="0">reset</button>
				<button type="button" class="hide" id="aModal_btn_1">OK1</button>
				<button type="button" class="hide" id="aModal_btn_2">OK2</button>
				<button type="button" class="hide" id="aModal_btn_3">OK3</button>
				<button type="button" class="hide" id="aModal_btn_4">OK4</button>
				<button type="button" class="hide" id="aModal_btn_5">OK5</button>
				<button type="button" class="hide" id="aModal_btn_6">OK6</button>
				<button type="button" class="hide" id="aModal_btn_7">OK7</button>
				<button type="button" class="hide" id="aModal_btn_8">OK8</button>
				<button type="button" class="hide" id="aModal_btn_9">OK9</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
jQuery(function($){
	
	var aModal_v_content='null';
	var aModal_v_type='text';
	var aModal_v_func=function(){};

	var aModal_mini_id=0;
	var aModal_mini_content='null';
	var aModal_mini_type='text';
	var aModal_mini_func=function(){};	
	
	var aModal_load=function(content,type,func,mini){
		mini=mini||0;
		var obj=(mini==0)?$('#aModal_msg'):$('#aModal_mini');
		switch(type){
			case 'url':
				obj.load(content,func);
				break;
			case 'html':
				obj.html(content);
				$('#aModal_javascript').html(func);	//艾玛，没有callback，当时用尽各种办法，几天后才想到直接把func塞进一个js容器即可。
				break;
			case 'text':
				obj.text(content);
				$('#aModal_javascript').html(func);
				break;					
			default:
				bootbox.alert('你输入的是什么，鄙人无法识别！');
				break;
		}
	}
	
	jQuery.aModal={
		load:function(title,content,func,type){
			title=title||'弹出层操作窗';	//默认
			content=content||'';	//默认
			type=type||'url';		//默认
			func=func||function(){};		//默认
			$('#aModal').modal();
			if(content==''){
				$('#aModal_msg').find('h1').text('什么也没有输入！你是在玩我么？');
			}else{
				$('#aModal_title').text(title);
				aModal_load(content,type,func);
				aModal_v_content=content;
				aModal_v_type=type;				
				aModal_v_func=func;			
			}
		},
		reload:function(content_renew,func_renew,type_renew){
			content_renew=content_renew||aModal_v_content;
			func_renew=func_renew||aModal_v_func;
			type_renew=type_renew||aModal_v_type;
			aModal_load(content_renew,type_renew,func_renew);
		},
		close:function(tipstay,content,color){
			if(tipstay){
				$('#aModal_tipmsg').attr('tipstay',1);
				switch(tipstay){
					case 1:
						break;
					case 2:
						content+='(3秒后刷新本页面...)';
						setTimeout(function(){window.location.reload();},3000);
						break;
				}
				if(content){this.tips(content,color);}
			}
			$('#aModal').modal('hide');
		},
		label:function(tipmsg){
			if(tipmsg){
				$('#aModal_tipmsg').html(tipmsg);
			}
		},		
		btn:function(num,txt,css,func){
			num=num||0;
			if(num<0){
				num=Math.abs(num);
				var obj=$('#aModal_btn_'+num);
				obj.removeAttr('class');
				obj.addClass('hide');
				obj.unbind('click');
				return false;
			}
			txt=txt||'重置刷新';			
			var obj=$('#aModal_btn_'+num);
			var nof=function(){
				alert('没有定义按钮功能，你点我做什么？');
			}
			if(css){
				func=func||nof;
				obj.text(txt);
				obj.addClass('btn btn-sm '+css);
				obj.removeClass('hide');
				obj.unbind('click');
				obj.bind('click',func);					
			}else{	//无任何参数，表示直接定位按钮为“重置刷新”。可允许指定按钮号码和按钮文字
				obj.text(txt);
				obj.addClass('btn btn-sm');
				obj.removeClass('hide');
				obj.unbind('click');
				obj.bind('click',function(){aModal_load(aModal_v_content,aModal_v_type,aModal_v_func)});			
			}
		},
		tips:function(content,color,stay,pos,time,title,image,mini){
			title=title||'提示';							//默认
			content=content||'这是一个消息提醒框';		//默认
			color=color||'';		//默认黑色，绿色为“success”，红色“error”，蓝色“info”，黄色“warning”，叠加“ gritter-light”可改为明色系。
			pos=pos||'center';
			stay=stay||false;
			time=time*1000||5000;
//			speed=speed||0;
			image=image||null;
			mini=mini||0;
			var light=(mini==0)?'':' gritter-light';
			if(color=='error'&&!stay){
				stay=true;
			}		
			if(!stay){
				title+='(<i>'+(time/1000)+'秒后自动关闭</i>)';
			}
			$.gritter.add({
				title: title,
				text: content,
				image: image,
				sticky: stay,
				time: time,
//				speed:1,
				class_name: 'gritter-'+pos+' gritter-'+color+light
			});	
		},
		set_refresh:function(YesNo){
			YesNo=YesNo||1;
			var tit=(YesNo==1)?'*':'';
			$('#aModal_btn_0').attr('refresh',YesNo);
			$('#aModal_refresh_title').text(tit);
		}
	}
	
	jQuery.aModal_mini={
		load:function(title,content,func,type){
			title=title||'弹出层操作窗(迷你)';	//默认
			content=content||'';	//默认
			type=type||'url';		//默认
			func=func||function(){};		//默认
			if(content==''){
				$.aModal.tips('什么也没有输入！你是在玩我么？','error');
			}else{
				var mini=$('#aModal_mini').attr('val');
				if(!mini){
					var mini_id=$.gritter.add({
						title: "【"+title+"】",
						text: '<div id="aModal_mini" val="1"><h1 class="center">loading...</h1></div>',
						sticky: true,
						class_name: 'gritter-light gritter-info gritter-center'
					});
					aModal_mini_id=mini_id;
				}
				aModal_load(content,type,func,1);
				aModal_mini_content=content;
				aModal_mini_type=type;				
				aModal_mini_func=func;					
			}
		},
		reload:function(content_renew,func_renew,type_renew){
			content_renew=content_renew||aModal_mini_content;
			func_renew=func_renew||aModal_mini_func;
			type_renew=type_renew||aModal_mini_type;
			aModal_load(content_renew,type_renew,func_renew,1);
		},	
		close:function(content,color){
			if(content){this.tips(content,color);}
			$.gritter.remove(aModal_mini_id);
		},
//		label:function(tipmsg){
//			if(tipmsg){
//				$('#aModal_tipmsg').html(tipmsg);
//			}
//		},		
		tips:function(content,color,stay,pos,time,title,image){
			$.aModal.tips(content,color,stay,pos,time,title,image,1);
		},		
//		btn_bind:function(bind_obj,bind_func,bind_txt,bind_keepbind){
//			var bindnow=function(obj,func,txt,keepbind){
//				if(!obj){
//					bootbox.alert('你不是要绑定吗？');
//					return false;
//				};		//默认
//				func=func||function(){bootbox.alert('为什么你绑定我却什么也不做！')};		//默认
//				keepbind=keepbind||0;
//				txt=txt||'';
//				if(keepbind!=0){
//					obj.unbind('click');
//				} 
//				if(txt!=''){
//					obj.text(txt);
//				}
//				obj.bind('click',func);				
//			}
//			setTimeout(bindnow(bind_obj,bind_func,bind_txt,bind_keepbind),3000);
//		}
	}
	
	$('#aModal_msg').slimScroll({
		height: '500px'
    });	
	$('#aModal').on('hidden.bs.modal',function (){
		var stay=$('#aModal_tipmsg').attr('tipstay');
		var refresh=$('#aModal_btn_0').attr('refresh');
//		$.gritter.remove(aModal_mini_id);//关闭大窗口的时候，同时关闭小窗口。
		if(refresh==1){
			window.location.reload();
		}
		if(stay==0){
			$.gritter.removeAll();
		}
		$('#aModal_tipmsg').attr('tipstay',0);		
		$('#aModal_msg').html('<h1 class="center">loading...</h1>');
		$('#aModal_tipmsg').text('');
		$('#aModal_javascript').html('');
		$('#aModal_footer').find('button').each(function(i,e){
			$(this).removeAttr('class');
			$(this).addClass('hide');
			$(this).unbind('click');
		});
	});
	
//实例
/*
示例：刷新，重置的3种定义。

	$.aModal.btn(1,'重置顺序','btn-info',function(){
		$.aModal.reload();
	});
	$.aModal.btn(4,'刷新');	
	$.aModal.btn();	
	$.aModal.tips('你好');	

	$('#hello').click(function(){
		var h='<h1 class="center">这是一个测试html页面</h1>';
        $.aModal.load('test',h,function(){alert('hello,i am dengwei!');},'html');
//      $.aModal.load('test','hello word!',null,'text');
        $.aModal.btn(1,'快点我','btn-info',function(){
        	bootbox.alert('我是邓伟');
        });
        $.aModal.btn(2,'点我很危险','btn-danger',function(){
        	$.aModal.tips('骗你的','error');
        });
        $.aModal.btn(3,'美女','btn-success',function(){
        	$.aModal.tips('你成功看到了','success');
        });
	});
	
	
	
	
 */
	
});
</script>
<!-- #section:aModal end-->